package ink.xiaobaibai.common;

import ink.xiaobaibai.enumOxy.PayType;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @description: 微信退款对象
 * @author: 小白白
 * @create: 2021-06-06
 **/

@Data
public class WxReturnObj {

    public WxReturnObj(String out_trade_no, String out_refund_no, BigDecimal refund, BigDecimal total, String reason) {
        this.out_trade_no = out_trade_no;
        this.out_refund_no = PayType.REFUND_PAY.getOrderPrefix() + out_refund_no;
        this.amount = new Amount((int) (refund.doubleValue() * 100), (int) (total.doubleValue() * 100));
        this.reason = reason;
        this.notify_url = WxCommon.NOTIFY_URL;
    }

    /**
     * 原订单号
     */
    private String out_trade_no;

    /**
     * 自定义退款订单号
     */
    private String out_refund_no;

    /**
     * 退款金额设定
     */
    private Amount amount;

    /**
     * 退款原因
     */
    private String reason;

    /**
     * 回调地址
     */
    private String notify_url;

    @Data
    private class Amount {

        public Amount(Integer refund, Integer total) {
            this.refund = refund;
            this.total = total;
        }

        /**
         * 退款金额
         */
        private Integer refund;
        /**
         * 原订单金额
         */
        private Integer total;
        private String currency = "CNY";
    }

}
